import React, { Component } from 'react';
import { Switch, Route, Redirect } from 'react-router-dom'
import Beforeeach from './beforeEach';
class Routerview extends Component {
  render() {
    const { routes } = this.props
    return (
      <Switch>
        {
          routes.length > 0 && routes.map((v, i) => {
            return (
              v.component 
                ? <Route path={ v.path } render={ props => <Beforeeach { ...props } { ...v }/> }  key={i}></Route>
                : <Redirect from={ v.from } to={v.to} key={i} exact/>


                /**
                 * <Route path={  /home }  render={}></Route>
                 * <Route path={  /detail}  render={}></Route>
                 * <Route path={ /login }  render={}></Route>
                 * <Reirect from={ / } to={ /home }>
                 * <Route render={}></Route>
                 * 
                */
            )
          })
        }
      </Switch>
    );
  }
}

export default Routerview;
